<template>
    <div style="margin-top: 77px;max-width: 960px;margin: 0 auto;">
    <div style="margin: auto;text-align: center">
            <h2>注册成功</h2>
            <h4>恭喜你，用户{{this.$route.params.username}}注册成功，还有 <span style="color: red">{{totalCount}}</span> 秒跳往登录界面</h4>
            <h2><a href="/" style="color: #409EFF">点击返回首页</a></h2>
        </div>
    </div>
</template>

<script>

    export default {

        name: "success",
        data() {
            return {
                timer: null,
                totalCount: ''

            }
        },
        created() {
            this.loginGo()
        },
        methods: {
            //10秒后进入跳转页面
            loginGo() {
                const TIME_COUNT = 10;
                if (!this.timer) {
                    this.totalCount = TIME_COUNT;
                    this.timer = setInterval(() => {
                        if (this.totalCount > 0 && this.totalCount <= TIME_COUNT) {
                            this.totalCount--;
                        } else {
                            clearInterval(this.timer);
                            this.timer = null;
                            //跳转的页面写在此处
                            this.$router.push({
                                path: '/userLogin'
                            });
                        }
                    }, 1000)
                }
            }
        }
    };
</script>

<style scoped>

</style>